package com.ok.pay.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ok.common.domain.po.Result;
import com.ok.pay.domain.dto.OkOrderDTO;
import com.ok.pay.service.IOkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author lhw
 * @since 2024-05-06
 */
@Api(tags = "订单相关接口")
@RestController
@RequestMapping("/order")
@RequiredArgsConstructor
public class OkOrderController {
    private final IOkOrderService okOrderService;

    @ApiOperation("*创建订单")
    @PostMapping("/addOrder")
    public void addOrder(@RequestBody OkOrderDTO okOrderDTO){
        okOrderService.addOrder(okOrderDTO);
    }

    @ApiOperation("订单分页")
    @GetMapping("/page")
    public Result page(@RequestParam Integer pageNo,@RequestParam Integer pageSize,@RequestParam(required = false) String orderName){
        Page page = okOrderService.pageWith(pageNo, pageSize, orderName);

        return Result.success(page);
    }

}
